package com.example.zhugenew;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;

import com.example.zhugenew.adapter.VpAdapter;
import com.umeng.analytics.MobclickAgent;

import java.util.ArrayList;

public class introductionActivity extends AppCompatActivity {

    private ViewPager mVp;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_introduction);
        initView();
    }
    @Override
    public void onResume(){
        super.onResume();
        MobclickAgent.onResume(this);
    }

    @Override
    public void onPause(){
        super.onPause();
        MobclickAgent.onPause(this);
    }
    private void initView() {
        mVp = (ViewPager) findViewById(R.id.vp);
        View vp1 = LayoutInflater.from(this).inflate(R.layout.layout_vp1, null);
        View vp2 = LayoutInflater.from(this).inflate(R.layout.layout_vp2, null);
        Button btnGo = vp2.findViewById(R.id.btn_go);


        btnGo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SharedPreferences user = getSharedPreferences("user", MODE_PRIVATE);
                SharedPreferences.Editor edit = user.edit();
                edit.putBoolean("is",true);
                edit.commit();
                startActivity(new Intent(introductionActivity.this,HomeActivity.class));
            }
        });
        ArrayList<View> views = new ArrayList<>();
        views.add(vp1);
        views.add(vp2);
        VpAdapter vpAdapter = new VpAdapter(views);
        mVp.setAdapter(vpAdapter);

        SharedPreferences user = getSharedPreferences("user", MODE_PRIVATE);
        boolean is = user.getBoolean("is", false);
        if (is){
            startActivity(new Intent(introductionActivity.this,HomeActivity.class));

        }
    }
}